/*
package com.deli.springboot.testutils;

import org.apache.tomcat.util.http.fileupload.FileUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

public class UploadUtils {
    public void downloadFile(String fileName,HttpServletRequest request,
                             HttpServletResponse response){
        if(fileName!=null){
            //获取file绝对路径
            String realPath = request.getServletContext().getRealPath("file/");
            File file = new File(realPath,fileName);
            OutputStream out = null;
            if(file.exists()){
                //设置下载完毕不打开文件
                response.setContentType("application/force-download");
                //设置文件名
                response.setHeader("Content-Disposition", "attachment;filename="+fileName);
                try {
                    out = response.getOutputStream();
                    FileInputStream fileInputStream = new FileInputStream(file);
                    byte[] bytes = new byte[2014];
                    int lenght = -1;
                    while((fileInputStream.read(bytes))==-1){

                    }
                    out.write(FileUtils.readFileToByteArray(file));
                    out.flush();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }finally{
                    if(out != null){
                        try {
                            out.close();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }
            }
        }

    }
*/
